import 'package:flutter/material.dart';
import 'package:palmf_hid/common/values/values.dart';
import 'package:palmf_hid/generated/assets.dart';
import 'package:get/get.dart';

import 'connect_to_device_dialog_logic.dart';

class ConnectToDeviceDialogPage extends StatefulWidget {
  String title;

  ConnectToDeviceDialogPage(this.title);

  @override
  State<ConnectToDeviceDialogPage> createState() =>
      _ConnectToDeviceDialogPageState(title);
}

class _ConnectToDeviceDialogPageState extends State<ConnectToDeviceDialogPage> {
  final logic = Get.put(ConnectToDeviceDialogLogic());
  final state = Get.find<ConnectToDeviceDialogLogic>().state;
  String title;

  _ConnectToDeviceDialogPageState(this.title);

  @override
  Widget build(BuildContext context) {
    return Dialog(
      child: Container(
        padding: const EdgeInsets.symmetric(vertical: 15),
        decoration: BoxDecoration(
          color: MyColor.c_FFF2F2F2,
          borderRadius: BorderRadius.circular(12),
        ),
        width: 650,
        height: 188,
        child: Column(
          children: [
            Image.asset(
              Assets.imagesBells,
              width: 40,
            ),
            const SizedBox(
              height: 10,
            ),
            const Text(
              "正在帮您尝试连接，5秒后重试",
              style: TextStyle(fontSize: 14, color: MyColor.c_CC000000),
            ),
            const SizedBox(
              height: 10,
            ),
             Text(
              title,
              style: TextStyle(fontSize: 12, color: MyColor.c_99000000),
            ),
            const SizedBox(
              height: 10,
            ),
            Obx(() => Container(
                alignment: Alignment.center,
                padding: const EdgeInsets.symmetric(
                  vertical: 10,
                ),
                child: Text("${state.leaveTime}s",
                    style: const TextStyle(
                      fontSize: 14,
                      color: MyColor.account_color,
                      decoration: TextDecoration.underline,
                    )))),
          ],
        ),
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<ConnectToDeviceDialogLogic>();
    super.dispose();
  }
}
